// TabBarPage.cpp : implementation file
//

#include "stdafx.h"
#include "tabbars.h"
#include "TabBarPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTabBarPage property page

IMPLEMENT_DYNCREATE(CTabBarPage, CPropertyPage)

//##ModelId=431C34C802EE
CTabBarPage::CTabBarPage() : CPropertyPage(CTabBarPage::IDD)
{
	//{{AFX_DATA_INIT(CTabBarPage)
	//}}AFX_DATA_INIT
	CIni ini;
	ini.Read(g_szIniPathName);

	ini.GetBoolValue(lpszTabbar,lpszShowIcon,m_bShowIcon,cfg_bShowIcons);
	ini.GetBoolValue(lpszTabbar,lpszEnableShellMenu,m_bUseShellMenu,!cfg_bNoShellContext);
	ini.GetBoolValue(lpszTabbar,lpszLimitWnd,m_bLimitWnd,cfg_bUseWindowLimit);
	ini.GetBoolValue(lpszTabbar,lpszShowRcName,m_bRcName,cfg_bDispRC);
	ini.GetBoolValue(lpszTabbar,lpszShowRcLang,m_bRcLanguage,cfg_bDispResLang);
	ini.GetBoolValue(lpszTabbar,lpszShowRcType,m_bRcType,cfg_bDispResType);
	ini.GetBoolValue(lpszTabbar,lpszShowRcID,m_bRcID,cfg_bDispRID);
	ini.GetValue(lpszTabbar,lpszMaxWnd,m_nMaxWnd,cfg_iWindowLimit);
	ini.GetValue(lpszTabbar,lpszOrderBy,m_nAddMode,(int)cfg_iAddOrder);
	ini.GetValue(lpszTabbar,lpszInitPos,m_nDockPos,(int)cfg_iOrientation);

	ini.Clear();
}

//##ModelId=431C34C802EF
CTabBarPage::~CTabBarPage()
{
}

//##ModelId=431C34C8034D
void CTabBarPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTabBarPage)
	DDX_Control(pDX, IDC_SPIN_MAXWND, m_spinWaxWnd);
	DDX_Check(pDX, IDC_CHk_ID, m_bRcID);
	DDX_Check(pDX, IDC_CHk_LANGUAGE, m_bRcLanguage);
	DDX_Check(pDX, IDC_CHK_LIMITWND, m_bLimitWnd);
	DDX_Check(pDX, IDC_CHk_RC, m_bRcName);
	DDX_Check(pDX, IDC_CHK_SHELLMENU, m_bUseShellMenu);
	DDX_Check(pDX, IDC_CHK_SHOWICON, m_bShowIcon);
	DDX_Check(pDX, IDC_CHk_TYPE, m_bRcType);
	DDX_Text(pDX, IDC_EDIT_MAXWND, m_nMaxWnd);
	DDX_Radio(pDX, IDC_RAD_ADDF, m_nAddMode);
	DDX_Radio(pDX, IDC_RAD_TOP, m_nDockPos);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTabBarPage, CPropertyPage)
	//{{AFX_MSG_MAP(CTabBarPage)
	ON_BN_CLICKED(IDC_CHk_ID, OnCHkID)
	ON_BN_CLICKED(IDC_CHk_LANGUAGE, OnCHkLANGUAGE)
	ON_BN_CLICKED(IDC_CHK_LIMITWND, OnChkLimitwnd)
	ON_BN_CLICKED(IDC_CHk_RC, OnCHkRC)
	ON_BN_CLICKED(IDC_CHK_SHELLMENU, OnChkShellmenu)
	ON_BN_CLICKED(IDC_CHK_SHOWICON, OnChkShowicon)
	ON_BN_CLICKED(IDC_CHk_TYPE, OnCHkTYPE)
	ON_EN_CHANGE(IDC_EDIT_MAXWND, OnChangeEditMaxwnd)
	ON_BN_CLICKED(IDC_RAD_ADDB, OnRadAddb)
	ON_BN_CLICKED(IDC_RAD_ADDF, OnRadAddf)
	ON_BN_CLICKED(IDC_RAD_BOTTOM, OnRadBottom)
	ON_BN_CLICKED(IDC_RAD_TOP, OnRadTop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabBarPage message handlers

//##ModelId=431C34C8035C
BOOL CTabBarPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	UpdateData(FALSE);
	GetDlgItem(IDC_EDIT_MAXWND)->EnableWindow(m_bLimitWnd);
	m_spinWaxWnd.SetRange(1,250);
	m_spinWaxWnd.EnableWindow(m_bLimitWnd);
	
	SetModified();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//##ModelId=431C34C8034B
BOOL CTabBarPage::OnApply() 
{
	UpdateData(TRUE);
	
	cfg_bShowIcons = m_bShowIcon;
	cfg_bNoShellContext = !m_bUseShellMenu;
	
	cfg_bUseWindowLimit = m_bLimitWnd;
	cfg_bDispRC = m_bRcName;
	cfg_bDispResLang = m_bRcLanguage;
	cfg_bDispResType = m_bRcType;
	cfg_bDispRID = m_bRcID;
	cfg_iWindowLimit = m_nMaxWnd;
	cfg_iAddOrder = (AddOrder)m_nAddMode;
	cfg_iOrientation = (SnapOrientations)m_nDockPos;

	CIni ini;
	ini.Read(g_szIniPathName);

	ini.SetBoolValue(lpszTabbar,lpszShowIcon,m_bShowIcon);
	ini.SetBoolValue(lpszTabbar,lpszEnableShellMenu,m_bUseShellMenu);
	ini.SetBoolValue(lpszTabbar,lpszLimitWnd,m_bLimitWnd);
	ini.SetBoolValue(lpszTabbar,lpszShowRcName,m_bRcName);
	ini.SetBoolValue(lpszTabbar,lpszShowRcLang,m_bRcLanguage);
	ini.SetBoolValue(lpszTabbar,lpszShowRcType,m_bRcType);
	ini.SetBoolValue(lpszTabbar,lpszShowRcID,m_bRcID);
	ini.SetValue(lpszTabbar,lpszMaxWnd,m_nMaxWnd);
	ini.SetValue(lpszTabbar,lpszOrderBy,m_nAddMode);
	ini.SetValue(lpszTabbar,lpszInitPos,m_nDockPos);
	
	ini.Write(g_szIniPathName);
	ini.Clear();

	return CPropertyPage::OnApply();
}

//##ModelId=431C34C8036C
void CTabBarPage::OnCHkID() 
{
	SetModified();
}

//##ModelId=431C34C8036E
void CTabBarPage::OnCHkLANGUAGE() 
{
	SetModified();
}

//##ModelId=431C34C8038A
void CTabBarPage::OnChkLimitwnd() 
{
	m_bLimitWnd = !m_bLimitWnd;
	GetDlgItem(IDC_EDIT_MAXWND)->EnableWindow(m_bLimitWnd);
	m_spinWaxWnd.EnableWindow(m_bLimitWnd);
	SetModified();
}

//##ModelId=431C34C8038C
void CTabBarPage::OnCHkRC() 
{
	SetModified();
}

//##ModelId=431C34C80399
void CTabBarPage::OnChkShellmenu() 
{
	SetModified();
}

//##ModelId=431C34C8039B
void CTabBarPage::OnChkShowicon() 
{
	SetModified();
}

//##ModelId=431C34C803A9
void CTabBarPage::OnCHkTYPE() 
{
	SetModified();
}

//##ModelId=431C34C803B9
void CTabBarPage::OnChangeEditMaxwnd() 
{
	SetModified();
}

//##ModelId=431C34C803BB
void CTabBarPage::OnRadAddb() 
{
	SetModified();
}

//##ModelId=431C34C803C8
void CTabBarPage::OnRadAddf() 
{
	SetModified();
}


//##ModelId=431C34C803D8
void CTabBarPage::OnRadBottom() 
{
	SetModified();
}

//##ModelId=431C34C803DA
void CTabBarPage::OnRadTop() 
{
	SetModified();
}
